<!--
 * @Author: DUST
 * @Date: 2023-05-16 16:39:43
 * @LastEditors: DUST
 * @LastEditTime: 2023-05-19 11:53:20
 * @FilePath: \vite-project\src\components\antModal.vue
 * @Description: 
 * undefined
-->
<template>
  <a-modal
    :width="width"
    :footer="false"
    :destroyOnClose="true"
    :closable="false"
    :visible="visible"
  >
    <div class="ModalBox">
      <div class="modalTitle">{{ props.title }}</div>
      <div class="modalContent">
        <slot></slot>
      </div>
      <div class="footer">
        <a-button v-if="showCancel" danger class="footerBtn cancel" :disabled="loading" @click="cancel">
          取消
        </a-button>
        <a-button class="footerBtn confirm" type="primary" :loading="loading" @click="confirm">
          确认
        </a-button>
      </div>
    </div>
  </a-modal>
</template>

<script setup lang="ts">

const props = defineProps({
  width: {
    type: Number,
    default: () => 400
  },
  visible: {
    type: Boolean,
    default: () => false
  },
  loading: {
    type: Boolean,
    default: () => false
  },
  showCancel: {
    type: Boolean,
    default: () => true
  },
  title: {
    type: String,
    default: () => ""
  },
  type: {
    type: String,
    default: () => ""
  }
})
const emit = defineEmits(["confirm", "cancel"]);
const confirm  = () => {
  emit("confirm")
}
const cancel  = () => {
  emit("cancel")
}
</script>

<style lang="less" scoped>
.ModalBox {
  width: 100%;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  .modalTitle {
    width: 100%;
    font-size: 16px;
    font-weight: bold;
    display: flex;
    align-items: center;
    flex-direction: row;
    height: 40px;
    border-bottom: 1px solid #eee;
    padding: 0 10px;
    box-sizing: border-box;
    &::before {
      content: "";
      display: inline-block;
      width: 4px;
      height: 22px;
      background-color: @primary-color;
      margin-right: 5px;
    }
  }
  .modalContent {
    width: 100%;
    height: calc(100% - 80px);
    min-height: 50px;
    padding: 15px 0;
    box-sizing: border-box;
    max-height: 600px;
  }
  .ModalForm {
    width: 100%;
  }
  .footer {
    width: 260px;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    .footerBtn {
      width: 110px;
      height: 35px;
    }
  }
}
</style>